import React, {Component} from 'react';
import {Link} from 'react-router-dom';

class Test extends Component {

    constructor(props) {
        super(props);
        this.state = ({
            id: '',
            name: ''
        });
    }

    componentDidMount() {
        console.log(this.props);
        let id = this.props.match.params.id;
        let name = this.props.match.params.name;
        this.setState({
            id: id,
            name: name
        });
    }

    click() {
        let id = this.props.match.params.id;
        let name = this.props.match.params.name;
        console.log(id);
        console.log(name);
    }

    render() {
        let {id, name} = this.state;
        return (
            <div>
                <h1>{id}</h1>
                <h1>{name}</h1>
                <button onClick={this.click.bind(this)}>
                    <Link to={`/test/1/2`}>111</Link>
                </button>
            </div>
        );
    };
}


export default Test;